﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ServerPlatform.DataProvider;
using ServerPlatform.Mapping;
using MapEntities;


namespace WebApp
{
    public static class DataHelper
    {
        private static DALEntities.ProviderInfo[] providers = null;
        private static object synjObj = new object();

        public static MapDataResult GetMapData(MapEntities.MapDataRequest request)
        {
            MapProcessor processor = new MapProcessor(request);

            return processor.GetMapData();
        }


        public static DALEntities.ProviderInfo[] GetProviders()
        {
            lock (synjObj)
            {
                if (providers == null)
                {
                    providers = DataProviderFramework.GetProviders().ToArray();
                }
            }
            
            return providers;            
        }

        public static DALEntities.ViewSchema[] GetSchema(DALEntities.SchemaRequest request)
        {
            return DataProviderFramework.GetSchema(request).ToArray();
        }

        public static DALEntities.ViewResult GetViewResult(DALEntities.ViewRequest request)
        {
            return DataProviderFramework.GetViewResult(request);
        }


    }
}
